use strict;
use warnings;
use lib qw(lib);

use Test::More "no_plan";

use QA::Util;

use constant EMAIL_SUFFIX => '@mybugzilla.org';

my ($sel, $config) = get_selenium();

# Very simple test script to test if updating the preferred email
# passes successfully for different user privileges.
#
foreach my $user (qw(admin unprivileged)) {
    log_in($sel, $config, $user);
    $sel->click_ok("link=Preferences", undef, "Go to Preferences page");
    $sel->wait_for_page_to_load(WAIT_TIME);
    $sel->click_ok("link=Name and Password", undef, "Select the tab Name and Password");
    $sel->wait_for_page_to_load(WAIT_TIME);

    $sel->type_ok("preferred_email",
                  $config->{"${user}_user_username"} . EMAIL_SUFFIX,
                  "Enter preferred email");
    $sel->type_ok("Bugzilla_password", $config->{"${user}_user_passwd"},
                   "Enter user password");
    $sel->click_ok("update", undef, "Submit Changes to userprefs.cgi");
    $sel->wait_for_page_to_load_ok(WAIT_TIME);
    $sel->is_text_present_ok("The changes to your name and password have been saved");
    logout($sel);
}
